package com.tg.message.msg;

import android.text.TextUtils;

import com.appbase.custom.constant.EventConstants;
import com.tg.message.R;

import java.util.HashMap;
import java.util.Map;

public class MessageDisplayMapping {

    private static final Map<String, MessageDisplay> map = new HashMap<>();

    static {

        // 密码错误
        map.put(EventConstants.INVALID_ACC, new MessageDisplay(
                EventConstants.INVALID_ACC,
                R.drawable.ic_tange_global_icon_message_password_error,
                R.string.password_consecutive_errors,
                R.string.password_consecutive_errors,
                false));

        // 有人闯入
        map.put(EventConstants.INTRUDE, new MessageDisplay(
                EventConstants.INTRUDE,
                R.drawable.ic_tange_global_icon_message_lock_break,
                R.string.door_lock_been_break,
                R.string.door_lock_been_break,
                false));

        // 门铃呼叫
        map.put(EventConstants.DOORBELL_CALL, new MessageDisplay(
                EventConstants.DOORBELL_CALL,
                R.drawable.ic_tange_global_icon_message_call,
                R.string.message_filter_event_doorbell_call_answered,
                R.string.message_filter_event_doorbell_call_answered,
                false));

        map.put(EventConstants.DOORBELL_CALL_ANSWERED, new MessageDisplay(
                EventConstants.DOORBELL_CALL_ANSWERED,
                R.drawable.ic_tange_global_icon_message_call,
                R.string.message_filter_event_doorbell_call_answered,
                R.string.message_filter_event_doorbell_call_answered,
                false));

        map.put(EventConstants.DOORBELL_CALL_MISSED, new MessageDisplay(
                EventConstants.DOORBELL_CALL_MISSED,
                R.drawable.ic_tange_global_icon_message_call,
                R.string.message_filter_event_doorbell_call_missed,
                R.string.message_filter_event_doorbell_call_missed,
                false));

        map.put(EventConstants.LOCK_ABNORMAL, new MessageDisplay(
                EventConstants.LOCK_ABNORMAL,
                R.drawable.ic_tange_global_icon_message_lock_abnormal,
                R.string.message_type_abnormal,
                R.string.message_type_abnormal,
                false));

        map.put(EventConstants.LOCK_ALARM, new MessageDisplay(
                EventConstants.LOCK_ALARM,
                R.drawable.ic_tange_global_icon_message_lock_alert,
                R.string.message_type_alert,
                R.string.message_type_alert,
                false));

        map.put(EventConstants.DOORBELL_PASSBY, new MessageDisplay(
                EventConstants.DOORBELL_PASSBY,
                R.drawable.ic_tange_global_icon_message_stay,
                R.string.message_filter_event_doorbell_passby,
                R.string.message_filter_event_doorbell_passby,
                false));

        map.put(EventConstants.DOORBELL_STAY, new MessageDisplay(
                EventConstants.DOORBELL_STAY,
                R.drawable.ic_tange_global_icon_message_stay,
                R.string.message_filter_event_doorbell_stay,
                R.string.message_filter_event_doorbell_stay,
                false));

        map.put(EventConstants.SOUND, new MessageDisplay(
                EventConstants.SOUND,
                R.mipmap.voice,
                R.string.message_filter_event_sound,
                R.string.message_event_sound,
                false));

        map.put(EventConstants.LOW_TEMP, new MessageDisplay(
                EventConstants.LOW_TEMP,
                R.mipmap.icon_temperature,
                R.string.txt_low_temp_tip,
                R.string.txt_low_temp_tip,
                false));

        map.put(EventConstants.HIGH_TEMP, new MessageDisplay(
                EventConstants.HIGH_TEMP,
                R.mipmap.icon_temperature,
                R.string.txt_high_temp_tip,
                R.string.txt_high_temp_tip,
                false));

        map.put(EventConstants.LOW_HUMID, new MessageDisplay(
                EventConstants.LOW_HUMID,
                R.mipmap.icon_humidity,
                R.string.txt_low_humid_tip,
                R.string.txt_low_humid_tip,
                false));

        map.put(EventConstants.HIGH_HUMID, new MessageDisplay(
                EventConstants.HIGH_HUMID,
                R.mipmap.icon_humidity,
                R.string.txt_high_humid_tip,
                R.string.txt_high_humid_tip,
                false));

        // TODO: 和 PIR和为一个
        map.put(EventConstants.MOTION, new MessageDisplay(
                EventConstants.MOTION,
                R.mipmap.move,
                R.string.message_filter_event_move,
                R.string.message_event_move,
                false));

        // TODO: 和 MOTION和为一个
        map.put(EventConstants.PIR, new MessageDisplay(
                EventConstants.PIR,
                R.mipmap.move,
                R.string.message_event_move,
                R.string.message_event_move,
                false));

        map.put(EventConstants.BODY, new MessageDisplay(
                EventConstants.BODY,
                R.mipmap.person,
                R.string.message_filter_event_body,
                R.string.message_event_body,
                true));

        map.put(EventConstants.CAR_STATE, new MessageDisplay(
                EventConstants.CAR_STATE,
                R.drawable.ic_tange_global_icon_message_car,
                R.string.message_type_car,
                R.string.message_event_car,
                true));

        map.put(EventConstants.PET, new MessageDisplay(
                EventConstants.PET,
                R.drawable.ic_tange_global_icon_message_pet,
                R.string.message_filter_type_pet,
                R.string.message_found_pet,
                true));

        map.put(EventConstants.CAR_START, new MessageDisplay(
                EventConstants.CAR_START,
                R.mipmap.car_setoff,
                R.string.message_filter_event_start,
                R.string.message_filter_event_start,
                false));

        map.put(EventConstants.CAR_STOP, new MessageDisplay(
                EventConstants.CAR_STOP,
                R.mipmap.car_setoff,
                R.string.message_filter_event_stop,
                R.string.message_filter_event_stop,
                false));

        map.put(EventConstants.GSENSOR, new MessageDisplay(
                EventConstants.GSENSOR,
                R.mipmap.gsensor,
                R.string.message_filter_event_gsensor,
                R.string.message_filter_event_gsensor,
                false));

        map.put(EventConstants.LOWBATTERY, new MessageDisplay(
                EventConstants.LOWBATTERY,
                R.drawable.ic_tange_global_icon_message_battery,
                R.string.message_filter_event_lowbattery,
                R.string.message_filter_event_lowbattery,
                false));

        map.put(EventConstants.SPEED_UP, new MessageDisplay(
                EventConstants.SPEED_UP,
                R.mipmap.speed_up,
                R.string.message_filter_event_speed_up,
                R.string.message_filter_event_speed_up,
                false));

        map.put(EventConstants.SPEED_DOWN, new MessageDisplay(
                EventConstants.SPEED_DOWN,
                R.mipmap.speed_down,
                R.string.message_filter_event_speed_down,
                R.string.message_filter_event_speed_down,
                false));

        map.put(EventConstants.POWER_ON, new MessageDisplay(
                EventConstants.POWER_ON,
                R.mipmap.power_on,
                R.string.message_filter_event_power_on,
                R.string.message_filter_event_power_on,
                false));

        map.put(EventConstants.CAR_STOP, new MessageDisplay(
                EventConstants.CAR_STOP,
                R.mipmap.icon_event_park,
                R.string.message_filter_event_stop,
                R.string.message_filter_event_stop,
                false));

        map.put(EventConstants.GEOFENCE_ENTER, new MessageDisplay(
                EventConstants.GEOFENCE_ENTER,
                R.mipmap.geofence_enter,
                R.string.message_filter_event_geofence_enter,
                R.string.message_filter_event_geofence_enter,
                false));

        map.put(EventConstants.GEOFENCE_EXIT, new MessageDisplay(
                EventConstants.GEOFENCE_EXIT,
                R.mipmap.geofence_exit,
                R.string.message_filter_event_geofence_exit,
                R.string.message_filter_event_geofence_exit,
                false));

        map.put(EventConstants.CAR_SET_OFF, new MessageDisplay(
                EventConstants.CAR_SET_OFF,
                R.mipmap.car_setoff,
                R.string.message_filter_event_setoff,
                R.string.message_filter_event_setoff,
                false));

        map.put(EventConstants.CAR_PARK, new MessageDisplay(
                EventConstants.CAR_PARK,
                R.mipmap.power_on_small,
                R.string.message_filter_event_park,
                R.string.message_filter_event_park,
                false));


        map.put(EventConstants.LIVESTOCK, new MessageDisplay(
                EventConstants.LIVESTOCK,
                R.drawable.ic_tange_global_icon_message_livestock,
                R.string.message_type_livestock,
                R.string.message_type_livestock,
                true));
    }

    public static MessageDisplay get(String messageTag) {
        if (!map.containsKey(messageTag)) {
            return null;
        }
        return map.get(messageTag);
    }

    public static boolean isNoMediaEvent(String messageTag) {
        return TextUtils.equals(messageTag, EventConstants.LOW_TEMP)
                || TextUtils.equals(messageTag, EventConstants.HIGH_TEMP)
                || TextUtils.equals(messageTag, EventConstants.LOW_HUMID)
                || TextUtils.equals(messageTag, EventConstants.HIGH_HUMID)
                || TextUtils.equals(messageTag, EventConstants.LOWBATTERY);
    }
}
